package dipl.algorithm.math.fp.primitive;

/**
 * point in 3d real or 2d projectiive space
 */
public class Point3df {

	//
	// CONSTRUCTOR METHODS
	//

	public Point3df() {
		x = 0.0;
		y = 0.0;
		z = 0.0;
	}

	public Point3df( double x, double y, double z ) {
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public Point3df( Point3df other ) {
		x = other.x;
		y = other.y;
		z = other.z;
	}

	//
	// PUBLIC METHODS
	//

	/**
	 * Converts point from (x,y,w) to (x/w,y/w,1) if w != 0
	 */
	public void ToCartesian() {
		if( z == 0.0 ) return;
		x /= z;
		y /= z;
		z = 1.0;
	}

	/**
	 * Takes coordinates from given point
	 * @param other
	 */
	public void Set( Point3df other ) {
		x = other.x;
		y = other.y;
		z = other.z;
	}

	/**
	 * Takes given coordinates
	 * @param x
	 * @param y
	 * @param z
	 */
	public void Set( double x, double y, double z ) {
		this.x = x;
		this.y = y;
		this.z = z;
	}

	@Override
	public String toString() {
		return "(x:"+Double.toString( x )+", y:"+Double.toString( y )+", z:"+Double.toString( z )+")";
	}

	//
	// MEMBERS
	//

	public double x;
	public double y;
	public double z;
}
